package com.tenglong.teacher.ui.construction.model;

import android.content.Context;

import com.cuotibao.zhuoxiao.basics.utils.JsonUtils;
import com.tenglong.teacher.data.resultInfo.CategoryInfo;
import com.tenglong.teacher.ui.construction.contract.ChooseTypeContract;
import com.tenglong.teacher.ui.utils.JsonPareseAddress;

import java.util.Arrays;
import java.util.List;

public class ChooseTypeModel implements ChooseTypeContract.ChooseModel {
    private List<CategoryInfo> classList;
    private List<CategoryInfo> gradeList;

    @Override
    public List<CategoryInfo> getClasses(Context context) {
        if (classList!=null){
            return classList;
        }
        classList = Arrays.asList(JsonUtils.fromJson(JsonPareseAddress.readFromAsset(context, "class.json"),
                CategoryInfo[].class));
        return classList;
    }

    @Override
    public List<CategoryInfo> getGrades(Context context) {
        if (gradeList!=null){
            return gradeList;
        }
        gradeList = Arrays.asList(JsonUtils.fromJson(JsonPareseAddress.readFromAsset(context, "grade.json"),
                CategoryInfo[].class));
        return gradeList;
    }
}
